package homework.organizer;

import homework.entities.Tema;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

import com.examples.SimpleCalendarViewActivity;

public class HomeworkOrganizerActivity extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// The Homework Button // using teme_layout
		Button butonTeme = (Button) findViewById(R.id.butonHomework);
		butonTeme.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				LinearLayout main = (LinearLayout) findViewById(R.id.new_layout);
				main.removeAllViews();
				View teme = getLayoutInflater().inflate(R.layout.teme_layout,
						main);
				
				// The ADD button from Homework
				Button addHomework = (Button) findViewById(R.id.butonAddHomework);
				addHomework.setOnClickListener(new OnClickListener() {
		            public void onClick(View v) {
		                startActivity(new Intent(getApplicationContext(), HomeworkAddActivity.class));
		            }
		        });
				
				Button showHomework = (Button) findViewById(R.id.butonShowHomework);
				showHomework.setOnClickListener(new OnClickListener() {
					
					public void onClick(View v) {
						
						Intent data = new Intent(getApplicationContext(),Homeworks.class);
						startActivity(data);
						
					}
				});
				
				Button showInCalendar = (Button) findViewById(R.id.butonShowCalHomework);
				showInCalendar.setOnClickListener(new OnClickListener() {
					
					public void onClick(View v) {
						
						Intent intent = new Intent(getApplicationContext(), SimpleCalendarViewActivity.class);
						Homeworks homeworkLoader = new Homeworks();
						homeworkLoader.populateWithHomework();
						ArrayList<Tema> homeworks = homeworkLoader.getHomeworks();
						
						
						Bundle data = new Bundle();
						data.putSerializable("homeworks", homeworks);
						
						intent.putExtra("data", data);
						
						startActivity(intent);
						
						
					}
				});
				
				
			}
		});

		// The Schedule Button
		Button butonOrar = (Button) findViewById(R.id.butonSchedule);
		butonOrar.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				LinearLayout main = (LinearLayout) findViewById(R.id.new_layout);
				main.removeAllViews();
				View orar = getLayoutInflater().inflate(R.layout.orar_layout,
						main);
				
				// The ADD button from Schedule
                Button addSchedule = (Button) findViewById(R.id.butonAddSchedule);
                addSchedule.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        startActivity(new Intent(getApplicationContext(), ScheduleAddActivity.class));
                        
                    }
                });
			}
		});

		
		// The Exams Button // using teme_layout
		Button butonExams = (Button) findViewById(R.id.butonExams);
		butonExams.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                LinearLayout main = (LinearLayout) findViewById(R.id.new_layout);
                main.removeAllViews();
                View exams = getLayoutInflater().inflate(
                        R.layout.teme_layout, main);
                // The ADD button from Exams
                Button addExam = (Button) findViewById(R.id.butonAddHomework);
                addExam.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {
                        startActivity(new Intent(getApplicationContext(), ExamsAddActivity.class));
                    }
                });
            }
        });
		
		// The Leisure Button // using teme_layout
		Button butonLeisure = (Button) findViewById(R.id.butonLeisure);
		butonLeisure.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				LinearLayout main = (LinearLayout) findViewById(R.id.new_layout);
				main.removeAllViews();
				View leisure = getLayoutInflater().inflate(
						R.layout.teme_layout, main);
			}
		});
		
		// The Calendar Button
		Button butonCalendar = (Button) findViewById(R.id.butonCalendar);
		butonCalendar.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				
				Intent whatever = new Intent(getApplicationContext(), SimpleCalendarViewActivity.class);
				startActivity(whatever);
				
			}
		});

		// The Destroy Button
		Button butonDestroy = (Button) findViewById(R.id.butonDestroy);
		butonDestroy.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(), Destroy.class));
			}
		});

	}

}